/*
 * FAtoms.h
 *
 *  Created on: May 13, 2012
 *      Author: marchi
 */

#ifndef FATOMS_H_
#define FATOMS_H_
#include "Atoms.h"
#include "HeaderTrj.h"
#include "typedefs.h"



class FAtoms: public Atoms {
	bool firsttime;
	void ReadaStep(FstreamC * );
	void ReadaStep(FstreamF * );
	void ReadaStep(std::ifstream &);
	void moveOffset(FstreamC *);
	void moveOffset(FstreamF *);
	void moveOffset(std::ifstream &);
	vector<double> rd;
public:
	FAtoms(): firsttime(true), Atoms(){};
	FAtoms(const int y): firsttime(true),Atoms(y){};
	FAtoms(const Atoms & y): firsttime(true),Atoms(y){};
	FAtoms(const AtomIndex & y): firsttime(true),Atoms(y){};

	virtual ~FAtoms();
	void setrd(vector<double> & rdx) {rd=rdx;};
	double getrd(int n){return rd[n];}

	friend Fstream & operator+=(Fstream & fin, FAtoms & y){
		if(FstreamC * finC=dynamic_cast<FstreamC *> (&fin))
			y.moveOffset(finC);
		else if(FstreamF * finF=dynamic_cast<FstreamF *> (&fin))
			y.moveOffset(finF);

		return fin;
	}

	friend std::ifstream & operator+=(std::ifstream & fin,FAtoms & y){
		y.moveOffset(fin);
		return fin;
	}

	friend Fstream & operator>>(Fstream & fin, FAtoms & y){
		if(FstreamC * finC=dynamic_cast<FstreamC *> (&fin))
			y.ReadaStep(finC);
		else if(FstreamF * finF=dynamic_cast<FstreamF *> (&fin))
			y.ReadaStep(finF);
		return fin;
	}

	friend std::ifstream & operator>>(std::ifstream & fin, FAtoms & y){
		y.ReadaStep(fin);
		return fin;
	}

};

#endif /* FATOMS_H_ */
